package DependencyModeling;

import java.util.ArrayList;

public class DataItem implements Comparable<DataItem> {
	public int count;
	public int size;
	public Double support;
	public ArrayList<String> items;
	public Boolean Trimmed;
	
	public DataItem(ArrayList<String> items)
	{
		this.items = items;
		this.count = 0;
		this.size = items.size();
		this.support = 0.0;
		this.Trimmed = false;
	}

	public void SetSupport(Double newValue)
	{
		this.support = newValue;
	}
	public void SetTrimmed(Boolean newValue)
	{
		this.Trimmed = newValue;
	}
	
	public boolean IsSuperSetOf(DataItem compare)
	{
		boolean stillTrue = true;
		
		for (String item : compare.items)
		{
			stillTrue = this.items.contains(item);
			if (!stillTrue)
				return false;
		}
		return true;
	}
	
	@Override
	public boolean equals(Object item)
	{
		if (item.getClass() != null && item.getClass() == DataItem.class)
		{
			DataItem compare = (DataItem) item;
			if (this.items.size() == compare.items.size())
			{
				return compare.IsSuperSetOf(this);
			}
		}
		return false;
	}
	
	@Override
	public int compareTo(DataItem item) {
		if (this.equals(item))
			return 0;
		else
		{
			return (this.items.size()<item.items.size()) ? -1 : 1; 
		}	
	}
}
